<?php

namespace App\Service;

use App\Model\ReportModel;
use EasySwoole\ORM\Exception\Exception;
use Throwable;

class ReportService extends BaseService
{
    /**
     * @param $uid
     * @param $content
     * @param $images
     * @return array
     * @throws Exception
     * @throws Throwable
     */
    public function report($uid, $content, $images): array
    {
        $par = [
            'uid' => $uid,
            'content' => $content,
            'images' => json_encode($images)
        ];

        $res = ReportModel::create()->addComment($par);
        if (!$res) {
            return [
                'result' => false,
                'msg' => '提交失败'
            ];
        }

        return [
            'result' => true,
            'msg' => '提交成功',
            'data' => 'success'
        ];
    }
}